Remove unnecessary includes.
authorTor Lillqvist <tml@novell.com>
Wed, 9 Nov 2005 12:35:56 +0000 (12:35 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Wed, 9 Nov 2005 12:35:56 +0000 (12:35 +0000)
2005-11-09  Tor Lillqvist  <tml@novell.com>

* gdk/win32/gdkwindow-win32.c: Remove unnecessary includes.

(_gdk_win32_get_adjusted_client_rect): Remove this two-line
function which was used only in one place.

(get_outer_rect): Use _gdk_win32_adjust_client_rect().

(gdk_window_set_geometry_hints): If we have identical minimum and
maximum size hints, remove the resize and maximize
decorations/functions. (#104514)

If we have a maximum size hint, remove the maximize
decoration/function but ensure the resize decoration/function is
available. Otherwise ensure both resize and maximize
decorations/functions are there.

(set_or_clear_style_bits): Factored out common code from
gdk_window_set_decorations() and gdk_window_set_functions().

Hack the window style setting once more: Only touch the window
style bits corresponding to the GdkWMDecoration or GdkWMFunction
parameter bitmasks. Hopefully this finally is the correct thing to
do. We used to clear all other bits than those that were being
set, or set all other bits than those that were being cleared.

Take into account that adding or removing decorations leaves the
window's outer size unchanged, i.e., the client area's size and
position change. This is apparently not what we want, so change
also the window's (outer) position and size appropriately so that
the client area's position and size stay constant.

gtk-demo's color selector dialog is now non-resizable like on X11
(I tested with metacity in GNOME). Torn off menus are shrinkable
vertically but have a maximum size, and are not maximizable or
minimizable, like on X11.

(gdk_window_set_decorations, gdk_window_set_functions): Let
set_or_clear_decorations() do most of the job.

* gdk/win32/gdkprivate-win32.h: Remove declaration of
_gdk_win32_get_adjusted_client_rect().

ChangeLog
ChangeLog.pre-2-10
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkwindow-win32.c

index 91a5b42b79aa4d8fc2613ab5306a8d3f20630005..f14a6cb5fe5440008a3dbedefe5f5c8704850994 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2005-11-09  Tor Lillqvist  <tml@novell.com>
+
+       * gdk/win32/gdkwindow-win32.c: Remove unnecessary includes.
+
+       (_gdk_win32_get_adjusted_client_rect): Remove this two-line
+       function which was used only in one place.
+
+       (get_outer_rect): Use _gdk_win32_adjust_client_rect().
+
+       (gdk_window_set_geometry_hints): If we have identical minimum and
+       maximum size hints, remove the resize and maximize
+       decorations/functions. (#104514)
+
+       If we have a maximum size hint, remove the maximize
+       decoration/function but ensure the resize decoration/function is
+       available. Otherwise ensure both resize and maximize
+       decorations/functions are there.
+
+       (set_or_clear_style_bits): Factored out common code from
+       gdk_window_set_decorations() and gdk_window_set_functions(). 
+
+       Hack the window style setting once more: Only touch the window
+       style bits corresponding to the GdkWMDecoration or GdkWMFunction
+       parameter bitmasks. Hopefully this finally is the correct thing to
+       do. We used to clear all other bits than those that were being
+       set, or set all other bits than those that were being cleared.
+
+       Take into account that adding or removing decorations leaves the
+       window's outer size unchanged, i.e., the client area's size and
+       position change. This is apparently not what we want, so change
+       also the window's (outer) position and size appropriately so that
+       the client area's position and size stay constant.
+
+       gtk-demo's color selector dialog is now non-resizable like on X11
+       (I tested with metacity in GNOME). Torn off menus are shrinkable
+       vertically but have a maximum size, and are not maximizable or
+       minimizable, like on X11.
+
+       (gdk_window_set_decorations, gdk_window_set_functions): Let
+       set_or_clear_decorations() do most of the job.
+
+       * gdk/win32/gdkprivate-win32.h: Remove declaration of
+       _gdk_win32_get_adjusted_client_rect().
+
 2005-11-09  Tor Lillqvist  <tml@novell.com>
 
        * gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32)
index 91a5b42b79aa4d8fc2613ab5306a8d3f20630005..f14a6cb5fe5440008a3dbedefe5f5c8704850994 100644 (file)
@@ -1,3 +1,47 @@
+2005-11-09  Tor Lillqvist  <tml@novell.com>
+
+       * gdk/win32/gdkwindow-win32.c: Remove unnecessary includes.
+
+       (_gdk_win32_get_adjusted_client_rect): Remove this two-line
+       function which was used only in one place.
+
+       (get_outer_rect): Use _gdk_win32_adjust_client_rect().
+
+       (gdk_window_set_geometry_hints): If we have identical minimum and
+       maximum size hints, remove the resize and maximize
+       decorations/functions. (#104514)
+
+       If we have a maximum size hint, remove the maximize
+       decoration/function but ensure the resize decoration/function is
+       available. Otherwise ensure both resize and maximize
+       decorations/functions are there.
+
+       (set_or_clear_style_bits): Factored out common code from
+       gdk_window_set_decorations() and gdk_window_set_functions(). 
+
+       Hack the window style setting once more: Only touch the window
+       style bits corresponding to the GdkWMDecoration or GdkWMFunction
+       parameter bitmasks. Hopefully this finally is the correct thing to
+       do. We used to clear all other bits than those that were being
+       set, or set all other bits than those that were being cleared.
+
+       Take into account that adding or removing decorations leaves the
+       window's outer size unchanged, i.e., the client area's size and
+       position change. This is apparently not what we want, so change
+       also the window's (outer) position and size appropriately so that
+       the client area's position and size stay constant.
+
+       gtk-demo's color selector dialog is now non-resizable like on X11
+       (I tested with metacity in GNOME). Torn off menus are shrinkable
+       vertically but have a maximum size, and are not maximizable or
+       minimizable, like on X11.
+
+       (gdk_window_set_decorations, gdk_window_set_functions): Let
+       set_or_clear_decorations() do most of the job.
+
+       * gdk/win32/gdkprivate-win32.h: Remove declaration of
+       _gdk_win32_get_adjusted_client_rect().
+
 2005-11-09  Tor Lillqvist  <tml@novell.com>
 
        * gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32)
index 2ec70d49f8695831cd6572c6d1eb446ac2727247..0489dd36cbc5feacf54e0a5dbf6fc70c5bf4339c 100644 (file)
@@ -356,9 +356,6 @@ HRGN          _gdk_win32_gdkregion_to_hrgn  (GdkRegion   *region,
 void   _gdk_win32_adjust_client_rect   (GdkWindow *window,
                                         RECT      *RECT);
 
-void   _gdk_win32_get_adjusted_client_rect (GdkWindow *window,
-                                            RECT      *RECT);
-
 void    _gdk_selection_property_delete (GdkWindow *);
 
 void    _gdk_dropfiles_store (gchar *data);
index 5c867d3260693778fae20878646356398a36d3c8..6989710c80f7ccc35f1bc1b3040d634def553908 100644 (file)
 #include <config.h>
 #include <stdlib.h>
 
-#include "gdk.h" /* gdk_rectangle_intersect */
-#include "gdkevents.h"
-#include "gdkpixmap.h"
-#include "gdkwindow.h"
-#include "gdkdisplay.h"
+#include "gdk.h"
 #include "gdkprivate-win32.h"
 #include "gdkinput-win32.h"
 
@@ -206,14 +202,6 @@ _gdk_win32_adjust_client_rect (GdkWindow *window,
   API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
 }
 
-void
-_gdk_win32_get_adjusted_client_rect (GdkWindow *window,
-                                    RECT      *rect)
-{
-  GetClientRect (GDK_WINDOW_HWND (window), rect);
-  _gdk_win32_adjust_client_rect (window, rect);
-}
-
 static GdkColormap*
 gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
 {
@@ -901,16 +889,11 @@ get_outer_rect (GdkWindow *window,
                gint       height,
                RECT      *rect)
 {
-  LONG style, exstyle;
-      
-  style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
-  exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
-      
   rect->left = rect->top = 0;
   rect->right = width;
   rect->bottom = height;
       
-  API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
+  _gdk_win32_adjust_client_rect (window, rect);
 }
 
 static void
@@ -1240,6 +1223,7 @@ gdk_window_resize (GdkWindow *window,
   else
     {
       RECT outer_rect;
+
       get_outer_rect (window, width, height, &outer_rect);
 
       GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
@@ -1641,6 +1625,27 @@ gdk_window_set_geometry_hints (GdkWindow      *window,
                               geometry->max_width, geometry->max_height));
     }
 
+  if ((geom_mask & GDK_HINT_MIN_SIZE) &&
+      (geom_mask & GDK_HINT_MAX_SIZE) &&
+      geometry->min_width == geometry->max_width &&
+      geometry->min_height == geometry->max_height)
+    gdk_window_set_decorations (window,
+                               GDK_DECOR_ALL |
+                               GDK_DECOR_RESIZEH |
+                               GDK_DECOR_MAXIMIZE);
+  else if (geom_mask & GDK_HINT_MAX_SIZE)
+    {
+      gdk_window_set_decorations (window,
+                                 GDK_DECOR_ALL |
+                                 GDK_DECOR_MAXIMIZE);
+      gdk_window_set_decorations (window,
+                                 GDK_DECOR_RESIZEH);
+    }
+  else
+    gdk_window_set_decorations (window,
+                               GDK_DECOR_RESIZEH |
+                               GDK_DECOR_MAXIMIZE);
+
   if (geom_mask & GDK_HINT_BASE_SIZE)
     {
       GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
@@ -2286,7 +2291,8 @@ gdk_window_shape_combine_mask (GdkWindow *window,
                               GDK_WINDOW_HWND (window),
                               GDK_WINDOW_HWND (mask)));
 
-      _gdk_win32_get_adjusted_client_rect (window, &rect);
+      GetClientRect (GDK_WINDOW_HWND (window), &rect);
+      _gdk_win32_adjust_client_rect (window, &rect);
 
       OffsetRgn (hrgn, -rect.left, -rect.top);
       OffsetRgn (hrgn, x, y);
@@ -2488,18 +2494,54 @@ gdk_window_set_group (GdkWindow *window,
   g_warning ("gdk_window_set_group not implemented");
 }
 
+static void
+set_or_clear_style_bits (GdkWindow *window,
+                        gboolean   clear_bits,
+                        int        bits)
+{
+  LONG style, exstyle;
+  RECT rect, before, after;
+
+  style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+  exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+
+  GetClientRect (GDK_WINDOW_HWND (window), &before);
+  after = before;
+  AdjustWindowRectEx (&before, style, FALSE, exstyle);
+
+  if (clear_bits)
+    style &= ~bits;
+  else
+    style |= bits;
+
+  SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
+
+  AdjustWindowRectEx (&after, style, FALSE, exstyle);
+
+  GetWindowRect (GDK_WINDOW_HWND (window), &rect);
+  rect.left += after.left - before.left;
+  rect.top += after.top - before.top;
+  rect.right += after.right - before.right;
+  rect.bottom += after.bottom - before.bottom;
+
+  SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+               rect.left, rect.top,
+               rect.right - rect.left, rect.bottom - rect.top,
+               SWP_FRAMECHANGED | SWP_NOACTIVATE | 
+               SWP_NOREPOSITION | SWP_NOZORDER);
+}
+
 void
 gdk_window_set_decorations (GdkWindow      *window,
                            GdkWMDecoration decorations)
 {
-  LONG style, bits;
-  const LONG settable_bits = WS_BORDER|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
+  int bits;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
   
-  GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s%s%s%s%s%s%s\n",
+  GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s %s%s%s%s%s%s\n",
                           GDK_WINDOW_HWND (window),
-                          (decorations & GDK_DECOR_ALL ? "ALL " : ""),
+                          (decorations & GDK_DECOR_ALL ? "clearing" : "setting"),
                           (decorations & GDK_DECOR_BORDER ? "BORDER " : ""),
                           (decorations & GDK_DECOR_RESIZEH ? "RESIZEH " : ""),
                           (decorations & GDK_DECOR_TITLE ? "TITLE " : ""),
@@ -2507,8 +2549,6 @@ gdk_window_set_decorations (GdkWindow      *window,
                           (decorations & GDK_DECOR_MINIMIZE ? "MINIMIZE " : ""),
                           (decorations & GDK_DECOR_MAXIMIZE ? "MAXIMIZE " : "")));
 
-  style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
-
   bits = 0;
 
   if (decorations & GDK_DECOR_BORDER)
@@ -2524,16 +2564,7 @@ gdk_window_set_decorations (GdkWindow      *window,
   if (decorations & GDK_DECOR_MAXIMIZE)
     bits |= WS_MAXIMIZEBOX;
 
-  if (decorations & GDK_DECOR_ALL)
-    style |= settable_bits, style &= ~bits;
-  else
-    style &= ~settable_bits, style |= bits;
-  
-  SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
-  SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-               0, 0, 0, 0,
-               SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
-               SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+  set_or_clear_style_bits (window, (decorations & GDK_DECOR_ALL), bits);
 }
 
 gboolean
@@ -2567,22 +2598,19 @@ void
 gdk_window_set_functions (GdkWindow    *window,
                          GdkWMFunction functions)
 {
-  LONG style, bits;
-  const LONG settable_bits = (WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU);
+  int bits;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
   
-  GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s%s%s%s%s%s\n",
+  GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s %s%s%s%s%s\n",
                           GDK_WINDOW_HWND (window),
-                          (functions & GDK_FUNC_ALL ? "ALL " : ""),
+                          (functions & GDK_FUNC_ALL ? "clearing" : "setting"),
                           (functions & GDK_FUNC_RESIZE ? "RESIZE " : ""),
                           (functions & GDK_FUNC_MOVE ? "MOVE " : ""),
                           (functions & GDK_FUNC_MINIMIZE ? "MINIMIZE " : ""),
                           (functions & GDK_FUNC_MAXIMIZE ? "MAXIMIZE " : ""),
                           (functions & GDK_FUNC_CLOSE ? "CLOSE " : "")));
 
-  style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
-
   bits = 0;
 
   if (functions & GDK_FUNC_RESIZE)
@@ -2596,16 +2624,7 @@ gdk_window_set_functions (GdkWindow    *window,
   if (functions & GDK_FUNC_CLOSE)
     bits |= WS_SYSMENU;
   
-  if (functions & GDK_FUNC_ALL)
-    style |= settable_bits, style &= ~bits;
-  else
-    style &= ~settable_bits, style |= bits;
-  
-  SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
-  SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-               0, 0, 0, 0,
-               SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
-               SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+  set_or_clear_style_bits (window, (functions & GDK_FUNC_ALL), bits);
 }
 
 static void